package com.atguigu.guli.service.edu.feign.fallback;

import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.edu.feign.OssFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class OssFeignClientFallback implements OssFileService {
    @Autowired
    StringRedisTemplate stringRedisTemplate;
    @Override
    public R test() {
        return R.error().message("访问osstest失败");
    }
    //对删除失败的头像进行熔断处理
    @Override
    public R delete(String path, String module) {
        log.error("删除文件失败，文件路径: {},文件模块: {}", path, module);
        BoundHashOperations<String, String,String> hashOps =
                stringRedisTemplate.boundHashOps("teacher:delfail:avatars");
        hashOps.put(path, module);
        return R.error().message("文件删除失败！");
    }

}
